Page({
  data: {
    bannerImages: [] // 用于存放轮播图图片路径
  },

  onLoad: function () {
    this.fetchBannerImages()
  },

  fetchBannerImages: function () {
    const that = this;
    wx.request({
      url: 'http://192.168.125.217:8080/api/image/list',
      method: 'GET',
      success(res) {
        if (res.data.code === 200) {
          const courtImages = res.data.data.filter(img => img.type === 'court');
          const fullUrls = courtImages.map(item => 'http://192.168.125.217:8080' + item.url);
          console.log("✅ 成功获取轮播图数据：", fullUrls);  // ✅ 打印数组
          that.setData({
            bannerImages: fullUrls
          });
        } else {
          wx.showToast({
            title: '轮播图加载失败',
            icon: 'none'
          });
        }
      },
      fail(err) {
        wx.showToast({
          title: '网络错误',
          icon: 'none'
        });
      }
    });
  }
  ,

  navigateTovenueReservation: function() {
    wx.navigateTo({
      url: '/pages/venueReservation/venueReversation'
    })
  }
})
